<template>
	<div class="dashboard-container">
		<div class="shouye-t" style="margin-top: 5px;">
			<span style="color:#FF5722; font-weight:bold;">{{name}}，STATE管理平台欢迎您！</span>
		</div>
		<div v-show="showHome">
			<fieldset v-show="showAcount">
				<legend>财务统计汇总</legend>
				<div>
					<div style="display: flex;">
						<Card style="flex: 1;margin: 5px; background:rgb(25, 190, 107); color:#fff;">
							<p slot="title" class="ff">今日新增用户</p>
							<div>
								<span>{{ list.toNumber == null ? 0 : list.toNumber }}</span>
							</div>
						</Card>
						<Card style="flex: 1;margin: 5px; background:rgb(25, 190, 107); color:#fff;">
							<p slot="title" class="ff">平台总用户</p>
							<div>
								<span>{{ list.sumNumber == null ? 0 : list.sumNumber }}</span>
							</div>
						</Card>
						<Card style="flex: 1;margin: 5px; background:rgb(255, 153, 0); color:#fff;">
							<p slot="title" class="ff">累计扣除Estate</p>
							<div>
								<span>{{ list.estateReduceRecharge == null ? 0 : list.estateReduceRecharge }}</span>
							</div>
						</Card>
						<Card style="flex: 1;margin: 5px; background:rgb(255, 153, 0); color:#fff;">
							<p slot="title" class="ff">累计扣除USDT</p>
							<div>
								<span>{{ list.usdtReduceRecharge == null ? 0 : list.usdtReduceRecharge }}</span>
							</div>
						</Card>
						<Card style="flex: 1;margin: 5px; background:rgb(237, 63, 20); color:#fff;">
							<p slot="title" class="ff">累计到账Estate</p>
							<div>
								<span>{{ list.estateAccrual == null ? 0 : list.estateAccrual }}</span>
							</div>
						</Card>
					</div>
					<div style="display: flex;">
						<Card style="flex: 1;margin: 5px; background:rgb(237, 63, 20); color:#fff;">
							<p slot="title" class="ff">累计到账USDT</p>
							<div>
								<span>{{ list.usdtAccrual == null ? 0 : list.usdtAccrual }}</span>
							</div>
						</Card>
						<Card style="flex: 1;margin: 5px; background:rgb(154, 102, 228); color:#fff;">
							<p slot="title" class="ff">累计提现Estate</p>
							<div>
								<span>{{ list.estateWithdrawal == null ? 0 : list.estateWithdrawal }}</span>
							</div>
						</Card>
						<Card style="flex: 1;margin: 5px; background:rgb(154, 102, 228); color:#fff;">
							<p slot="title" class="ff">累计提现USDT</p>
							<div>
								<span>{{ list.usdtWithdrawal == null ? 0 : list.usdtWithdrawal }}</span>
							</div>
						</Card>
						<Card style="flex: 1;margin: 5px; background:rgb(228, 108, 187); color:#fff;">
							<p slot="title" class="ff">累计充值Estate</p>
							<div>
								<span>{{ list.estateRecharge == null ? 0 : list.estateRecharge }}</span>
							</div>
						</Card>
						<Card style="flex: 1;margin: 5px; background:rgb(228, 108, 187); color:#fff;">
							<p slot="title" class="ff">累计充值USDT</p>
							<div>
								<span>{{ list.usdtRecharge == null ? 0 : list.usdtRecharge }}</span>
							</div>
						</Card>

						<!--<Card style="flex: 1;margin: 5px;" class="CardTransparent"></Card>-->
					</div>
				</div>
			</fieldset>
			<div class="base" style="margin-top: 20px;position: relative;" v-if="showNewList">
				<Card>
					<p slot="title">
						<span>最新参与众筹记录</span>
						<!--<span style="float: right;color: #2D8cF0;cursor: pointer;" @click="toMore">查看更多 ></span>-->
					</p>
					<Table stripe :columns="columns1" :data="newList" ref="table" :loading="loading"></Table>
				</Card>
			</div>
		</div>
		<img src="../../../assets/images/home-bg.png" width="100%" v-show="showBg">
	</div>
</template>

<script>
	export default {
		data() {
			return {
				name: localStorage.getItem('name'),
				list: [], // 汇总数据
				newList: [], // 最新记录
				showHome: true,
				showAcount: true,
				showNewList: true,
				showBg: false,
				loading: false,
				columns1: [{
						title: "个人ID",
						key: "uuid"
					},
					{
						title: "账号",
						key: "userName"
					},
					{
						title: "参与份额",
						key: "total"
					},
//					{
//						title: "Estate单价",
//						key: "exuuPrice"
//					},
					{
						title: "当前总支付",
						key: "payExuu",
						render: (h, params) => {
							return h("div", params.row.payType == "null" ? "#" : params.row.payType == 1 ? params.row.payExuu + " USDT" : params.row.payExuu + " Estate");
						}
					},
					{
						title: "参与时间",
						key: "createTime",
						render: (h, params) => {
							return h("div", params.row.createTime == "null" ? "#" : this.stringToTime(params.row.createTime));
						}
					}
				]
			}
		},
		methods: {
			getList() {
				this.axios.get('/admin/accounting/statistical').then(res => {
					if(res.data.code == 200) {
						this.list = res.data.data
					}
				})
			},
			toMore() {
//				this.$router.push('/house/manage')
			},
			getNewsList() {
				this.loading = true
				this.axios.post('/admin/index/get/newParticipate', {
					params: {
						current: 1, // 当前页【可选，默认1】
						size: 20 // 每页记录数【可选，默认20】
					}
				}).then(res => {
					if(res.data.code == 200) {
						this.newList = res.data.data.records
						this.loading = false
					}
				})
			}
		},
		created() {
			this.getList();
			this.getNewsList()
			let show
			this.axios.get('admin/index/authorize').then(res => {
				if(res.data.code == 200) {
					show = res.data.data
					// if (show.indexOf(1) == -1) {
					//   this.showHome = false
					//   this.showBg = true
					// } else {
					//   show.indexOf(4) == -1 ? (this.showAcount = false) : this.getList()
					//   show.indexOf(5) == -1 ? (this.showNewList = false) : this.getNewsList()
					// }
				}
			})
		},
		mounted() {
			this.$Message.config({
				top: 250
			})
		}
	}
</script>

<style>
	.shouye-t {
		margin-bottom: 10px;
		padding: 15px;
		line-height: 22px;
		border-left: 5px solid #2db7f5;
		border-radius: 0 2px 2px 0;
		background-color: #e9eaec;
	}
	
	.ivu-card-head p {
		font-weight: normal;
	}
	
	.CardTransparent {
		background: transparent;
		border: 0;
	}
	
	.CardTransparent:hover {
		box-shadow: 0 1px 6px rgba(0, 0, 0, 0);
	}
	
	.ivu-card-head .ff {
		color: #fff;
	}
</style>